package com.ccb.sc.common.modules.order.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 * @author ken
 * @version 1.0
 * @date 2020-09-25
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@Getter
public enum OrderStatus implements IEnum<Integer> {

    /**
     * 待支付
     */
    WAIT_PAY(0, "待支付"),

    /**
     * 待发货
     */
    WAIT_DELIVER(1, "待发货"),

    /**
     * 已发货
     */
    SHIPPED(2, "已发货"),

    /**
     * 已完成
     */
    FINISHED(3, "已完成"),

    /**
     * 已取消
     */
    CANCELED(4, "已取消"),

    /**
     * 退货退款
     */
    RETURN(5, "退货/售后"),

    /**
     * 已收货
     */
    RECEIVED(6, "已收货"),

    /**
     * 已评价
     */
    COMMENT(7, "已评价"),
    ;

    private int value;
    private String desc;

    OrderStatus(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public static OrderStatus getByValue(int value) {
        for (OrderStatus orderStatus : OrderStatus.values()) {
            if (value == orderStatus.getValue()) {
                return orderStatus;
            }
        }
        return null;
    }
}
